package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	g := gin.Default()
	group := g.Group("/index")
	group.GET("/test", Redirect)
	err := g.Run()
	if err != nil {
		return
	}
}
func Redirect(ctx *gin.Context) {
	var method = ctx.Request.Method
	switch method {
	case "get":
		ctx.JSON(http.StatusOK, gin.H{
			"msg": "get",
		})
		break
	case "post":
		ctx.JSON(http.StatusOK, gin.H{
			"msg": "post",
		})
		break
	default:
		ctx.JSON(http.StatusOK, gin.H{
			"msg": method,
		})
	}
}
